package com.briup.jz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.jz.bean.BasePrivilege;
import com.briup.jz.bean.BasePrivilegeExample;
import com.briup.jz.dao.BasePrivilegeMapper;
import com.briup.jz.service.BasePrivilegeService;
import com.briup.jz.utils.CustomerException;

@Service
public class BasePrivilegeServiceImpl implements BasePrivilegeService {

	@Autowired
	private BasePrivilegeMapper basePrivilegeMapper;
	@Override
	public void saveOrUpdate(BasePrivilege basePrivilege) throws CustomerException {
		// TODO Auto-generated method stub
		if(basePrivilege.getId()!=null) {
			basePrivilegeMapper.updateByPrimaryKey(basePrivilege);
		} else {
			basePrivilegeMapper.insert(basePrivilege);
		}
	}

	@Override
	public List<BasePrivilege> query(String name) {
		BasePrivilegeExample example = new BasePrivilegeExample();
		if(name!=null){
			example.createCriteria().andNameLike("%"+name+"%");
		}
		List<BasePrivilege> list = basePrivilegeMapper.selectByExample(example);
		return list;
	}

	@Override
	public void deleteById(String name) throws CustomerException {
	
		basePrivilegeMapper.deleteByPrimaryKey( name);

	}

	@Override
	public List<BasePrivilege> selectChilder() {
		return basePrivilegeMapper.selectChilder();
	}

}
